{include file="public/header" /} {include file="public/menu" /}
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
    <ul class="layui-tab-title site-demo-title">
        <li  class="layui-this"><a href="{:url('article/index')}">文章管理</a></li>
        <li><a href="{:url('article/postdata')}">添加文章</a></li>
    </ul>
    <div class="layui-body layui-tab-content site-demo site-demo-body">



        <div class="layui-main">
            <div id="">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend>筛选</legend>
                </fieldset>
                <form class="layui-form" action="{:url('article/index')}" method="get">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <label class="layui-form-label">文章标题</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" autocomplete="off" class="layui-input" placeholder="文章标题" value="{$title}">
                            </div>
                        </div>


                        <!--文章分类-->
                            <label class="layui-form-label">文章分类</label>
                            <div class="layui-input-inline">
                                <select name="cid" id="cid">
                                    <option value="">请选择分类</option>
                                    {volist name="cate" id="vo"}
                                    <option value="{$vo.id}" {if $cid==$vo.id } selected="" {/if}>{$vo.name} </option>
                                    {volist name="vo.cate_second" id="v"}
                                    <option value="{$v.id}" {if $cid==$v.id } selected="" {/if}>&nbsp;&nbsp;&nbsp;&nbsp;-- {$v.name} </option>
                                    {/volist}
                                    {/volist}
                                </select>
                            </div>




                        <div class="layui-inline">
                            <button class="layui-btn" lay-submit lay-filter="Search">搜索</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>



        <div class="layui-tab-item layui-show">
            <div class="layui-main">
                <div id="LAY_preview">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th width="300">标题</th>
                            <th>分类</th>
                            <th>是否显示</th>
                            <th>点击量</th>
                            <th>排序</th>
                            <th>添加时间</th>
                            <th>修改时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {volist name="articles" id="vo"}
                        <tr>
                            <td><a href="javascript:;" title="{$vo.title}">{$vo.title}</a></td>
                            <td>{$vo.cname}</td>
                            <td>{$vo.status}</td>
                            <td>{$vo.views}</td>
                            <td>{$vo.displayorder}</td>
                            <td>{$vo.addtime}</td>
                            <td>{$vo.updatetime}</td>
                            <td>
                                <a class="layui-btn layui-btn-mini" lay-event="edit" href="{:url('article/postdata',['id'=>$vo.id])}">编辑</a>
                                <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" href="javascript:data_del({$vo.id})">删除</a>
                            </td>
                        </tr>
                        {/volist}
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function data_del(id) {
        layui.use(['layer','laypage'], function() {
            var layer = layui.layer,
                laypage = layui.laypage,
                $ = layui.$;

            laypage.render({
                elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
                ,
                count: "50" //数据总数，从服务端得到
            });

            layer.confirm('确定删除？', {
                btn: ['确认', '取消']
            }, function(index, layero) {
                //按钮【按钮一】的回调
                $.post("{:url('article/del')}", { id: id }, function(res) {
                    //res就是返回的结果
                    var res = JSON.parse(res)
                    if (res.status == 200) {
                        layer.msg(res.msg);
                        location.reload();
                    } else {
                        layer.msg(res.msg)
                    }
                });
            }, function(index) {
                //按钮【按钮二】的回调
            });
        })
    }
</script>
{include file="public/footer" /}